function searchSort(value, arr) {
    for(let i = 0; i < arr.length - 1; i++) {
        for(let j = 0; j < arr.length - i - 1; j++) {
            let pre = Math.abs(arr[j] - value);
            let tail = Math.abs(arr[j+1] - value);
            if(pre > tail || (pre===tail && arr[j] > arr[j+1])) {
                let flag = arr[j];
                arr[j] = arr[j+1];
                arr[j+1] = flag;
            }
        }
    }
    let result = '';
    for(let i = 0; i<arr.length; i++) {
        console.log(arr[i]);
        result += arr[i];
        if(i !== arr.length - 1) {
            result += ' '
        }
    }
    console.log(result);
}
searchSort(100, [95,96,97,98,99,101,102,103,104,105]);